package io.gitee.zhucan123.core.config;

import org.springframework.core.convert.converter.Converter;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author: zhuCan
 * @date: 2020/2/25 11:02
 * @description:
 */
public class LocalDateConverter implements Converter<String, LocalDateTime> {

  @Override
  public LocalDateTime convert(String source) {
    if(source.isEmpty()){
      return null;
    }
    return LocalDateTime.from(DateTimeFormatter.ofPattern(JsonConfiguration.PATTERN).parse(source));
  }
}
